#!/usr/bin/env bash
kinit -k -t socialProduct_dev.keytab  socialProduct@SIITDMP.COM

d=$(date -d yesterday "+%Y%m%d")
echo $d
d=20180101
d=$1

hive -e "insert overwrite table  sl_app.article_category_result
partition (ctime='${d}')
select a.article_id,
if(b.category_1st = '' and c.platform_type_id != 6, '-1', a.category_1st),
if(b.category_2nd = '' and c.platform_type_id != 6, '-1', a.category_2nd) from
(select * from sl_app.article_category_result_external where category_1st != '') a
left join
(select * from sl_app.article_category_result_external where category_1st = '') b
on a.article_id = b.article_id
join (select pid, platform_type_id from sl_app.article_data_resource where ctime='${d}') c
on a.article_id = c.pid
;"
